/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using DaveSexton.DocProject.Engine;
using System.Xml;

namespace DaveSexton.DocProject.Sandcastle
{
	internal sealed class CreateConceptualBuildFilesBuildStep : BuildStep<SandcastleBuildEngine>
	{
		#region Public Properties
		public override string Name
		{
			get
			{
				return Resources.Text.CreateConceptualBuildFilesBuildStepName;
			}
		}
		#endregion

		#region Private / Protected
		private readonly string topicsFile, manifestFile, workingMetadataFolder, workingTopicsFolder, topicsFolder;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="CreateConceptualBuildFilesBuildStep" /> class.
		/// </summary>
		public CreateConceptualBuildFilesBuildStep(SandcastleBuildEngine engine, string topicsFile, string manifestFile, 
			string topicsFolder, string workingTopicsFolder, string workingMetadataFolder)
			: base(engine)
		{
			this.topicsFile = topicsFile;
			this.manifestFile = manifestFile;
			this.topicsFolder = topicsFolder;
			this.workingMetadataFolder = workingMetadataFolder;
			this.workingTopicsFolder = workingTopicsFolder;
		}
		#endregion

		#region Methods
		protected override void ExecuteInternal(BuildContext context)
		{
			context.TraceLine();
			context.TraceLine("Creating conceptual build manifest file: {0}", manifestFile);

			int companionFilesCount = TopicManagement.ConceptualTopicFileManager.CreateConceptualBuildFiles(
				topicsFile, manifestFile, topicsFolder, workingTopicsFolder, workingMetadataFolder);

			context.TraceLine(Resources.Text.Done);
			context.TraceLine();
			context.TraceLine("Created {0} companion XML file(s).", companionFilesCount);
		}

		protected override void CancelInternal(BuildContext context)
		{
			// do nothing
		}
		#endregion
	}
}
